package alg20241024;

import java.util.HashSet;
import java.util.Set;

public class Text {
    public int lengthOfLongestSubstring(String ss) {
        char[] s = ss.toCharArray();
        int left = 0, right = 0, n = s.length;
        int[] hash = new int[128];
        int ret = 0;
        while(right < n){
            hash[s[right]]++;   //进窗口
            while(hash[s[right]] > 1){
                hash[s[left++]]--;

            }
            ret = Math.max(ret, right-left+1);
            right++;
        }
        return ret;
    }

}
